<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            *****
            ****
            ***
            **
            *
            思路：双重for 循环，外层控制行，内层控制列
            i       num 的最大值
            0           5
            1           4
            2           3
            3           2
            4           1
            
            i + num = 5
            num = 5 - i;
        */
    
        for (let i = 5; i >0; i--) {
            let num = '';
            for (let j = 0; j < i; j++) {
                num = num + '*'; 
            } 
            console.log(num);
        }  
       
        console.log(`-----------案例---------`);
        /*
            *
            **
            ***
            ****
            *****

                 *
                **
               ***
              ****
             *****
        */
      
        for (let i = 0; i < 5; i++) {
             let num = '';
            for (let j = 0; j <= i; j++) {
                num =num+ '*';
                
            } 
             console.log(num);
        }  

        for (let i = 0; i < 5; i++) {
            let num = '';
            for (let k = 3; k >= i; k--) {
                num = num + ' '; 
            } 
            for (let j = 0; j <= i; j++) {
                num = num + '*'; 
            } 
            console.log(num);
        }  
    </script>
</body>

</html>